<?php

use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
/*
Route::get('/', function () {
    return view('welcome');
});*/
Route::group(['prefix'=>'admin','namespace'=>'Admin'],function (){
//登录显示
    Route::get('login','LoginController@index')->name('login');
//登录处理
    Route::post('login','LoginController@login')->name('admin.login');
    //验证码
    Route::get('captch','BaseController@captch')->name('admin.captch');
    Route::group(['middleware'=>['adminLogin'],'as'=>'admin.'],function (){
        //首页
        Route::get('index','IndexController@index')->name('index');
        //退出登录
        Route::get('logout','IndexController@logout')->name('logout');
        //用户列表
        Route::get('admin/index','AdminController@index')->name('admin.index');
        //添加用户视图
        Route::get('admin/add','AdminController@create')->name('admin.create');
        //添加用户处理
        Route::post('admin/add','AdminController@store')->name('admin.store');
        //删除用户处理
        Route::delete('admin/del/{id}','AdminController@del')->name('admin.del');
        //还原用户处理
        Route::get('admin/restore/{id}','AdminContRoller@restore')->name('admin.restore');
        //全选删除
        Route::delete('admin/delall','AdminController@delall')->name('admin.delall');
        //给用户分配角色
        Route::match(['get','post'],'admin/role/{admin}','AdminController@role')->name('admin.role');
        Route::get('email',function (){
        /*   Mail::raw('测试发送',(function(\Illuminate\Mail\Message $message){
               $message->to('2679652842@qq.com','曾');
               //主题名
               $message->subject('测试');
           }));*/
      /*  Mail::send('mail.reg',['user'=>'李四'],function (\Illuminate\Mail\Message $message){
            $message->to('2679652842@qq.com','曾');
            //主题名
            $message->subject('测试');

        });*/
        });
        //修改用户信息视图
        Route::get('admin/edit/{id}','AdminContRoller@edit')->name('admin.edit');
        //修改用户处理
        Route::put('admin/edit/{id}','AdminContRoller@update')->name('admin.edit');
        //用户组
        Route::get('role/node/{role}','RoleController@node')->name('role.node');
        Route::post('role/node/{role}','RoleController@nodeSave')->name('role.node');
        Route::resource('role','RoleController');
        //节点
        Route::resource('node','NodeController');
        //分类管理
        Route::resource('classify','ClassifyController');
        //图片上传
        Route::post('article/upfile','ArticleController@upfile')->name('article.upfile');
       //文章管理
        Route::resource('article','ArticleController');
        //教师账号管理
        Route::get('teacher/restore/{id}','TeacherController@restore')->name('teacher.restore');
        Route::resource('teacher','TeacherController');
        //学生课程表
        Route::resource('student_course','StudentCourseController');
        //学号批量生成视图
        Route::get('student/batch','StudentController@batch')->name('student.batch');
        //学号批量生成处理
        Route::post('student/batchs','StudentController@batchs')->name('student.batchs');
        //导出学生信息视图
        Route::match(['get','post'],'student/info','StudentController@info')->name('student.info');
        Route::resource('student','StudentController');
        //导出考试学生
        Route::match(['get','post'],'examinfo/examination','ExaminfoController@examination')->name('examinfo.examination');
        //考试信息表
        Route::resource('examinfo','ExaminfoController');
        //excel 测试
        Route::get('excel/index','ExcelController@index')->name('excel.index');
        //导入成绩lead
        Route::match(['get','post'],'grade/lead','GradeController@lead')->name('grade.lead');
        //导出成绩
        Route::match(['get','post'],'grade/export','GradeController@export')->name('grade.export');
        //成绩
        Route::resource('grade','GradeController');
    });
});

/**
 * 教师平台
 */
Route::group(['prefix'=>'teacher','namespace'=>'Teacher'],function (){
    //登录显示
    Route::get('login','LoginController@index')->name('login');
//登录处理
    Route::post('login','LoginController@login')->name('teacher.login');
    Route::group(['middleware'=>['teacherLoginIfAuth:teacher'],'as'=>'teacher.'],function (){
        Route::get('index','IndexController@index')->name('index');
        Route::resource('info','InformationController');
    });

});
